package no.ntnu.fp.model;

import no.ntnu.fp.utils.XmlParser;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class MeetingRoom extends Entity {
	private String name;
	private int capacity;
	
	public MeetingRoom(long id, String name, int capacity) {
		super(id);
		this.name = name;
		this.capacity = capacity;
	}

	public String getName() {
		return name;
	}

	public int getCapacity() {
		return capacity;
	}

	public MeetingRoom (Element rootNode) {
		super(rootNode);
	}

	@Override
	protected void initializeFromXml(Element rootNode) {
		this.id = Long.parseLong(XmlParser.getTextValue(rootNode, "id"));
		this.name = XmlParser.getTextValue(rootNode, "name");
		this.capacity = Integer.parseInt(XmlParser.getTextValue(rootNode, "capacity"));
	}

	@Override
	public Element toXml(Document dom) {
		Element rootElement = dom.createElement("meetingroom");
		rootElement.appendChild(XmlParser.createElementWithValue(dom, "id", id + ""));
		rootElement.appendChild(XmlParser.createElementWithValue(dom, "name", name));
		rootElement.appendChild(XmlParser.createElementWithValue(dom, "capacity", this.capacity + ""));
		return rootElement;
	}

	@Override
	public String toString() {
		return super.toString() + " Room name: " + getName();
	}

}
